<?php

namespace App\Admin\Controllers;

use App\Admin\Actions\SmsSendError\ResentSms;
use App\Models\SmsSendError;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class SmsSendErrorController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'SmsSendError';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new SmsSendError());

        $grid->column('id', __('Id'));
        $grid->column('mobile', '手机');
        $grid->column('action', '类别');
        $grid->column('resp_content', '返回内容');
        $grid->column('other_infos', '相关信息');
        $grid->column('created_at', '创建时间')->date('Ymd Hi');

        $grid->actions(function ($actions) {
            $actions->add(new ResentSms());
        });

        $grid->filter(function($filter){
            // 去掉默认的id过滤器
            $filter->disableIdFilter();
            // 在这里添加字段过滤器
            $filter->equal('action', '类别');
            $filter->equal('mobile', '手机');
        });

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(SmsSendError::findOrFail($id));



        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new SmsSendError());



        return $form;
    }
}
